package db

import (
	"github.com/jinzhu/gorm"
	"log"
	_ "github.com/jinzhu/gorm/dialects/postgres"
	"git.oschina.net/fanbuchi/xgggh/sms/model"
)
var mMaster *gorm.DB
func init() {
	postgres:="postgresql://feeds@localhost:26257/feeds?sslmode=disable"
	db, err := gorm.Open("postgres",postgres)
	if err !=nil{
		log.Fatal(err)
	}
	db.AutoMigrate(&model.Sms{})
	db.AutoMigrate(&model.Template{})
	db.AutoMigrate(&model.Channel{})
	mMaster=db
	//defer db.Close()
}

func Master() *gorm.DB{
	return mMaster.Debug()
}
